home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_basi / inputb20.zip / MAIN.BAS < prev    next >
BASIC Source File  |  1996-11-05  |  3KB  |  78 lines

  1. Attribute VB_Name = "SampleMainModule"
  2. ' Example of how to use InputBox
  3. ' You do NOT have to include this file in your projects
  4. ' See InputBox.Bas for more information
  5. '
  6. ' Tuomas Salste vbshop@netgate.net
  7.  
  8.  
  9. Option Explicit
  10.  
  11. Sub Main()
  12. ' This is where the demo starts
  13.  
  14. Dim UserName As Variant
  15. Dim UserPwd As Variant
  16.  
  17. ShowWelcomeMessage
  18.  
  19. ' Ask the user's name (default to "H. Hacker")
  20. UserName = InputBox("What is your name:", "Hello!", "H. Hacker")
  21.  
  22. If IsNull(UserName) Or UserName = "" Then
  23.     ' If the user pressed 'Cancel' or typed nothing
  24.     MsgBox "Why didn't you tell me your name?", 16, "I won't play with you!"
  25. Else
  26.     ' Continue if the user pressed 'OK'
  27.     MsgBox "Hello, " & UserName & "!", 48, "Nice to meet you!"
  28.  
  29.     ' Ask the user's password (max. 8 chars)
  30.     ' The password is shown as *'s on the screen
  31.     UserPwd = InputPassword("What is your password:", UserName, , , , , , 8)
  32.  
  33.     If IsNull(UserPwd) Or UserPwd = "" Then
  34.         ' If the user pressed 'Cancel' or gave no password
  35.         MsgBox "Are you afraid of telling me your password?", 32
  36.     Else
  37.         ' If the user pressed 'OK'
  38.         MsgBox "Haha! Your password is '" & UserPwd & "'!", 48, "Stupid password"
  39.     End If
  40. End If
  41.  
  42.  
  43. ShowRegistration
  44.  
  45. ' This is where the demo ends
  46. End
  47.  
  48. End Sub
  49.  
  50. Private Sub ShowRegistration()
  51.  
  52. Dim Msg As String
  53. Msg = Msg & "InputBox is shareware. This version is fully functional and comes with all the source code." & vbCrLf & vbCrLf
  54. Msg = Msg & "If you find InputBox useful for your own programs, please read readme.txt for details on registration." & vbCrLf
  55. Msg = Msg & "The registration fee is $10 and it includes all future updates." & vbCrLf & vbCrLf
  56. Msg = Msg & "Tuomas Salste" & vbCrLf
  57. Msg = Msg & "vbshop@netgate.net" & vbCrLf
  58. Msg = Msg & "http://www.netgate.net/~vbshop/vb.html"
  59. MsgBox Msg, 64, InputBoxVersionName
  60.  
  61. End Sub
  62.  
  63.  
  64. Private Sub ShowWelcomeMessage()
  65. ' Just shows a message box with some introductory text in it
  66.  
  67. Dim Msg As String
  68. Msg = Msg & "This is a demo program that demonstrates the use of the new InputBox functions." & vbCrLf & vbCrLf
  69. Msg = Msg & "To use the functions, add the following files to your project:" & vbCrLf
  70. Msg = Msg & "- InputBox.Frm" & vbCrLf
  71. Msg = Msg & "- InputBox.Bas" & vbCrLf & vbCrLf
  72. Msg = Msg & "Then simply call the InputBox function just like you did before" & vbCrLf
  73. Msg = Msg & "You can also use InputUCase, InputLCase and InputPassword!" & vbCrLf
  74. MsgBox Msg, 64, InputBoxVersionName
  75.  
  76. End Sub
  77.  
  78.